
TRIGGER PROCEDURE FOR WRITE OF MND_DET OLD BUFFER OLD_MND_DET.


{mfdeclre.i }
define new shared work-table wf_old_mnd_det like mnd_det.

HK:
do:
    if can-find(first dt_mstr where dt_table = "mnd_det" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(mnd_det), input "mnd_det").

    if not can-find ( first dt_mstr where dt_table = "mnd_det" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_mnd_det ) then do:
        create wf_old_mnd_det.
        if recid(wf_old_mnd_det)= -1 then .
    end.
    
    buffer-copy old_mnd_det to wf_old_mnd_det no-error.

    for each dt_mstr no-lock where dt_table = "mnd_det" and dt_type = "MOD" :
    
        case dt_field :

            when "mnd_nbr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_nbr, input mnd_det.mnd_nbr,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_select" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_mnd_det.mnd_select), input string(mnd_det.mnd_select),
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_label" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_label, input mnd_det.mnd_label,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_exec" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_exec, input mnd_det.mnd_exec,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_fkey" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_mnd_det.mnd_fkey), input string(mnd_det.mnd_fkey),
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_help" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_help, input mnd_det.mnd_help,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_canrun" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_canrun, input mnd_det.mnd_canrun,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_name" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_name, input mnd_det.mnd_name,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_user1, input mnd_det.mnd_user1,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd_user2, input mnd_det.mnd_user2,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

            when "mnd__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_mnd_det.mnd__qadc01, input mnd_det.mnd__qadc01,
                    input recid(mnd_det), input mnd_det.mnd_nbr, input string(mnd_det.mnd_select), input "", input "",
                    input "", input "", input "", input "").

        end.
    end.
end.

{hkdttrans.i}
